home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Language/OS - Multiplatform Resource Library
/
LANGUAGE OS.iso
/
pcr
/
pcr4_4.lha
/
DIST
/
debugnub
/
CirioNubLocalProcs.c
< prev
next >
Wrap
C/C++ Source or Header
|
1992-04-16
|
7KB
|
339 lines
/* begincopyright
Copyright (c) 1988-1990 Xerox Corporation. All rights reserved.
Use and copying of this software and preparation of derivative works based
upon this software are permitted. Any distribution of this software or
derivative works must comply with all applicable United States export
control laws. This software is made available AS IS, and Xerox Corporation
makes no warranty about the software, its performance or its conformity to
any specification. Any person obtaining a copy of this software is requested
to send their name and post office or electronic mail address to:
PCR Coordinator
Xerox PARC
3333 Coyote Hill Rd.
Palo Alto, CA 94304
endcopyright */
/*
* CirioNubLocalProcs.c
*
* Demers, November 5, 1990 9:14:40 am PST
*/
#include "xr/Errno.h"
#include "xr/Threads.h"
#include "xr/ThreadsBackdoor.h"
#include "xr/IncrementalLoad.h"
#include "xr/CirioNubLocalProcs.h"
#include "xr/CirioNubInnerProcs.h"
static bool CirioNubLocal_ignoreLockFailure = FALSE;
void
CirioNubLocalSetIgnoreLockFailure(ignore)
bool ignore;
{
CirioNubLocal_ignoreLockFailure = ignore;
}
bool
CirioNubLocalGetIgnoreLockFailure()
{
return CirioNubLocal_ignoreLockFailure;
}
static int
CirioNubLocalLock(gotLockP)
bool *gotLockP;
{
XR_ILError ile;
int i;
ile = XR_LockIncrementalLoadState(FALSE);
if( ile == NIL ) {
*gotLockP = TRUE;
return 0;
} else {
*gotLockP = FALSE;
return ((CirioNubLocal_ignoreLockFailure) ? 0 : (-1));
}
}
#define DCLLOCK bool gotLock
#define LOCK() { if(CirioNubLocalLock(&gotLock) != 0) return(-1); }
#define UNLOCK() { if(gotLock) (void)XR_UnlockIncrementalLoadState(); }
unsigned
CirioNubLocalNull(desiredVersion)
unsigned desiredVersion;
{
if( desiredVersion < CIRIO_NUB_LOCAL_PROCS_LOW_VERSION )
return CIRIO_NUB_LOCAL_PROCS_LOW_VERSION;
if( desiredVersion > CIRIO_NUB_LOCAL_PROCS_VERSION )
return CIRIO_NUB_LOCAL_PROCS_VERSION;
return desiredVersion;
}
int
CirioNubLocalGetThread(index, buf)
int index;
CirioNubThreadData buf;
{
return CirioNubInnerGetThread(index, buf);
}
int
CirioNubLocalPCtoInfo(pc, buf)
XR_Pointer pc;
CirioNubPCInfo buf;
{
int ans;
DCLLOCK;
LOCK();
ans = CirioNubInnerPCtoInfo(pc, buf);
UNLOCK();
return ans;
}
int
CirioNubLocalGetFileEntry(seqNum, buf)
unsigned seqNum;
CirioNubFileEntry buf;
{
int ans;
DCLLOCK;
LOCK();
ans = CirioNubInnerGetFileEntry(seqNum, buf);
UNLOCK();
return ans;
}
int
CirioNubLocalGetMatchingSymEntryByName(
symID, pattern, caseSensitive, wantedTypes, ignoredClasses,
numToSkip, buf
)
unsigned symID;
char *pattern;
bool caseSensitive;
unsigned wantedTypes;
unsigned ignoredClasses;
int numToSkip;
CirioNubSymEntry buf;
{
int ans;
DCLLOCK;
LOCK();
ans = CirioNubInnerGetMatchingSymEntryByName(
symID, pattern, caseSensitive,
wantedTypes, ignoredClasses, numToSkip, buf
);
UNLOCK();
return ans;
}
int
CirioNubLocalGetMatchingSymEntryByValue(
symID, val, wantedTypes, ignoredClasses, numToSkip, buf
)
unsigned symID;
unsigned val;
unsigned wantedTypes;
unsigned ignoredClasses;
int numToSkip;
CirioNubSymEntry buf;
{
int ans;
DCLLOCK;
LOCK();
ans = CirioNubInnerGetMatchingSymEntryByValue(
symID, val, wantedTypes, ignoredClasses, numToSkip, buf
);
UNLOCK();
return ans;
}
int
CirioNubLocalReplacePatchArea(pc, newPatchArea, newSize)
XR_Pointer pc;
XR_Pointer newPatchArea;
unsigned long newSize;
{
int ans;
struct CirioNubPCInfoRep pcir;
XR_ILFileEntry ilfe;
DCLLOCK;
if( newPatchArea == NIL ) {
newPatchArea = XR_calloc(1, newSize);
if( newPatchArea == NIL ) return (-ENOMEM);
}
LOCK();
ans = CirioNubInnerPCtoInfo(pc, &pcir);
if( ans >= 0 ) {
ilfe = NIL;
for(;;) {
ilfe = XR_ILGetPrevFileEntry(ilfe);
if( ilfe == NIL ) {
ans = -EINVAL;
break;
}
if( ilfe->ilfe_seqNum == pcir.fileSeqNum ) {
ilfe->ilfe_pAddr = ((caddr_t)(newPatchArea));
ilfe->ilfe_pBytes = newSize;
ans = 0;
break;
}
}
}
UNLOCK();
return ans;
}
/* OBSOLETE: */
int
CirioNubLocalLookupSymEntryByName(
sym, caseSensitive, externOnly, numToSkip, buf)
char *sym;
bool caseSensitive;
bool externOnly;
int numToSkip;
CirioNubSymEntry buf;
{
int ans;
DCLLOCK;
LOCK();
ans = CirioNubInnerGetMatchingSymEntryByName (
NIL, sym, caseSensitive, WANT_ALL_TYPES,
(externOnly ? IGNORE_INTERNAL : IGNORE_NONE),
numToSkip, buf
);
UNLOCK();
return ans;
}
int
CirioNubLocalSkipSymEntryByName(
symID, caseSensitive, externOnly, numToSkip, buf)
unsigned symID;
bool caseSensitive;
bool externOnly;
int numToSkip;
CirioNubSymEntry buf;
{
int ans;
DCLLOCK;
LOCK();
ans = CirioNubInnerGetMatchingSymEntryByName (
symID, NIL, caseSensitive, WANT_ALL_TYPES,
(externOnly ? IGNORE_INTERNAL : IGNORE_NONE),
numToSkip, buf
);
UNLOCK();
return ans;
}
int
CirioNubLocalLookupSymEntryByValue(val, numToSkip, buf)
unsigned val;
int numToSkip;
CirioNubSymEntry buf;
{
int ans;
DCLLOCK;
LOCK();
ans = CirioNubInnerGetMatchingSymEntryByValue (
NIL, val, WANT_ALL_TYPES, IGNORE_NONE, numToSkip, buf
);
UNLOCK();
return ans;
}
int
CirioNubLocalSkipSymEntryByValue(symID, numToSkip, buf)
unsigned symID;
int numToSkip;
CirioNubSymEntry buf;
{
int ans;
DCLLOCK;
LOCK();
ans = CirioNubInnerGetMatchingSymEntryByValue (
symID, 0, WANT_ALL_TYPES, IGNORE_NONE, numToSkip, buf
);
UNLOCK();
return ans;
}
int
CirioNubLocalLookupSymEntryByID(symID, buf)
unsigned symID;
CirioNubSymEntry buf;
{
return CirioNubLocalSkipSymEntryByValue( symID, 0, buf );
}
int
CirioNubLocalGetMaxThreads()
{
return XR_maxThreads;
}
int
CirioNubLocalGetThreadIndex(ct)
XR_CT ct;
{
int ans;
if( (ans = XR_ValidateCT(ct)) < 0 ) return ans;
return ct->ct_thread->t_index;
}
/*
* Get stuff from XR_JmpBuf
*
* This is not included in CirioNubLocalProcs.h
*/
XR_Pointer
CirioNubLocalSPFromJmpBuf(b)
XR_JmpBuf b;
{
return( XR_SP_FROM_JMP_BUF(b) );
}
XR_Pointer
CirioNubLocalPCFromJmpBuf(b)
XR_JmpBuf b;
{
return( XR_PC_FROM_JMP_BUF(b) );
}